package com.tju.Service.impl;


import com.tju.IDao.ResourcesMapper;
import com.tju.Service.ResourcesService;
import com.tju.Util.ResultDO;
import com.tju.model.MenuObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Boyu on 2017/2/27.
 */
@Service("resourcesServiceImpl")
@Slf4j
public class ResourcesServiceImpl implements ResourcesService {

    @Autowired
    private ResourcesMapper resourcesMapper;


    @Override
    public ResultDO<List<MenuObject>> getSystemMenuList() {
        ResultDO<List<MenuObject>> listResultDO = new ResultDO<>();
        try {
            List<MenuObject> menuObjects = resourcesMapper.selectByResourceType(0);
            listResultDO.setSuccess(true);
            listResultDO.setModule(menuObjects);
        }catch (Exception e)
        {
           log.error ("读取系统菜单失败：error,"+e.getMessage());
           listResultDO.setErrorCode("读取系统菜单失败");
        }
        return listResultDO;
    }
}
